<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单管理-车速递</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/mymain.mymain.css">
    <script type="application/javascript" src="../js/jquery-3.3.1.js"></script>
    <script type="application/javascript" src="../js/bootstrap.min.js"></script>
    <script type="application/javascript" src="../layui/layui.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>

</head>
<body style="position: static">

<div id="app" class="bgGray">
    <div data-v-95ac8d30="" class="header3">
        <div data-v-95ac8d30="" class="layout clear">
            <div data-v-95ac8d30="" class="left logo">
                <a data-v-95ac8d30="" href="../index.html">
                    <img data-v-95ac8d30=""
                         src="">
                </a>
            </div>
            <div data-v-95ac8d30="" class="header3Nav right">|<a data-v-95ac8d30="" href="mymain.html">我的订单</a>|<a
                    data-v-95ac8d30="" href="#">帮助中心</a>|<a data-v-95ac8d30="" href="javascript:void">退出</a>
            </div>
            <div data-v-95ac8d30="" class="header3User right">
                <i data-v-95ac8d30="" class="iconfont icon-phone"></i>
                <span data-v-95ac8d30="" class="sp1">400-919-8000</span>
                <span data-v-95ac8d30="" class="sp2">欢迎您，</span>
                <span data-v-95ac8d30="" class="sp3"></span>
            </div>
        </div>
    </div>
    <div class="userInfo">
        <div class="layout">
            <div class="userInfoCom clear">
                <div class="userInfoL left">
                    <div data-v-1cae2c34="" class="userNav">
                        <dl data-v-1cae2c34="" class="userMsg">
                            <dt data-v-1cae2c34="">
                                <img data-v-1cae2c34=""
                                     src="">
                            </dt>
                            <dd data-v-1cae2c34="">
                                <p data-v-1cae2c34=""></p>
                                <p data-v-1cae2c34="" class="p5 pp" style="">普卡会员</p>
                            </dd>
                        </dl>
                        <ul data-v-1cae2c34="" class="manNav">
                            <li data-v-1cae2c34="">
                                <a data-v-1cae2c34="" href="mymain.html" class="sel">订单管理</a>
                            </li>
                            <li data-v-1cae2c34="">
                                <a data-v-1cae2c34="" href="myinfo.html" class="">个人信息</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="userInfoR right">

                    <div class="orderManage manage">
                        <div class="orderManageTit manageTit clear">
                            <div class="left tit">订单管理</div>
                        </div>
                        <div class="orderType clear type">
                            <div class="sel">全部订单</div>
                        </div>
                        <!--                        layui中得TABLE-->
                        <div class="layui-tab-content">
                            <div>
                                <table class="layui-hide" id="test" lay-filter="test"
                                       style="margin-left: 300px"></table>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <div data-v-3aaf9db2="" class="footer2">
        <div data-v-3aaf9db2="" class="layout clear">
            <div data-v-3aaf9db2="" class="d1">
                <a data-v-3aaf9db2="" href="about.html">关于车速递</a></div>
        </div>
    </div>

</div>
<script type="text/javascript">
    $(function () {
        // sp3
        $.ajax({
            type: "get",
            url: "/carCourier/loginStusta.do",
            dataType: "json",
            success: function (data) {
                console.log(data)
                $(".sp3").html(data.info)
            }
        })
    })
</script>
<script>
    layui.use(['table', 'laydate', "laypage", "layer", 'carousel', 'upload', 'element', 'slider'], function () {
        //初始化table组件对象
        var table = layui.table
            , laypage = layui.laypage//分页的组件
            , layer = layui.layer//弹框
            , laydate = layui.laydate//日期组件
            , element = layui.element;//元素的操作

        //渲染table
        table.render({
            //z找到table  id叫test的组件
            elem: '#test'
            , id: "transferTable"
            , url: '/carCourier/orderSelect.do'
            , totalRow: true
            //这个很关键，就是解析 json数据库中数据的 一定要注意键值
            , cols: [[
                {field: 'id', title: '订单号', width: 110, unresize: true, sort: true, fixed: "left"}
                , {field: 'oprice', title: '订单金额', width: 110}
                , {field: 'name', title: '车型', width: 110}
                , {field: 'getCar', title: '取车地址', width: 110, sort: true}
                , {field: 'backCar', title: '还车地址', width: 110}
                , {field: 'status', title: '订单状态', width: 110, edit: 'text'}
                , {fixed: 'right', title: '操作',width: 178, align: 'center', toolbar: '#barDemo'}
            ]]
            , page: true //分页开启
        });
    });

    var active = {
        reload: function () {
            //执行重载
            table.reload('transferTable', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        }
    };

    $('.serchDiv .layui-btn').on('click', function () {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>


    function deleteOrder(id) {
        $.ajax({
            type:"post",
            url:"/carCourier/delete.do",
            dataType:"json",
            data: {"id":id},
            success:function(data){
                if(data.code==1){
                    alert("删除成功!")
                }
            }
        })
    }

    layui.use('table', function(){
        var table = layui.table;
        //监听工具条
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    deleteOrder(obj.data.id)
                    layer.close(index);
                });
            }
    });
    });

</script>

</body>
</html>